<?php
/* @var $this UserController */
/* @var $model User */

$this->menu=array(
	array('label'=>Yii::t('BackEnd','Profile'), 'url'=>array('profile')),
    array('label'=>Yii::t('BackEnd','Change Password'), 'url'=>array('changepassword')),
);
?>
<?= $this->renderPartial('//layouts/sidebar'); ?>
<?= CHtml::scriptFile(Yii::app()->request->baseUrl.'/js/validate_date.js'); ?>
<script>
    $(document).ready(function() {
        loadYear(<?= $birthday[0]; ?>);
        loadMonth(<?= $birthday[1]; ?>);
        loadDay(<?= $birthday[2]; ?>); 
    });
</script>

<section>
    <div class="heading_section">
        <span><?= Yii::t('BackEnd','Profile'); ?></span>
    </div>
    
    <div class="content">
        <div class="form">
        <div class="table">
        <?php $form=$this->beginWidget('CActiveForm', array(
        	'id'=>'user-profile-form',
            'htmlOptions' => array(
                'enctype' => 'multipart/form-data',
            ),
            'enableClientValidation'=>true,
        	'enableAjaxValidation'=>true,
            'clientOptions'=>array(
                'validateOnSubmit'=>true,
                'validateOnChange'=>true,
                'validateOnType'=>false,
            ),
        )); ?>
        
        	<div class="tr">
        		<div class="td"><?= $form->labelEx($model,'email'); ?></div>
        		<div class="td2" style="color: #000000;"><?= $model->email; ?></div>
        		<div class="td3"><?= $form->error($model,'email'); ?></div>
        	</div>
        
        	<div class="tr">
        		<div class="td"><?= $form->labelEx($model,'fullname'); ?></div>
        		<div class="td2"><?= $form->textField($model,'fullname',array('class'=>'input','size'=>30,'maxlength'=>50)); ?></div>
        		<div class="td3"><?= $form->error($model,'fullname'); ?></div>
        	</div>
        
        	<div class="tr">
        		<div class="td"><?= $form->label($model,'gender'); ?></div>
        		<div class="td2"><?= $form->dropDownList($model,'gender',User::model()->getGenderArray(),array('class'=>'input')); ?></div>
        		<div class="td3"><?= $form->error($model,'gender'); ?></div>
        	</div>
        
        	<div class="tr">
        		<div class="td"><?= $form->label($model,'birthday'); ?></div>
        		<div class="td2">
                    <select class="input" style="width: 55px;" name="day" id="day"></select>
                    <select class="input" style="width: 55px;" name="month" id="month" onchange="loadDay()"></select>
                    <select class="input" style="width: 80px;" name="year" id="year" onchange="loadDay()"></select>
                </div>
        		<div class="td3"></div>
        	</div>
            
            <?php if(!$model->isNewRecord) : ?>
            <?php 
                if($model->avatar == '0') :
                    $model->avatar = 'no-avatar.gif'; 
                endif; ?>
            <div class="tr">
                <div class="td" style="vertical-align: middle;"><?= CHtml::label('Ảnh đại diện cũ','old_avatar',array(' ')); ?></div>
                <div class="td2"><?= CHtml::image(Yii::app()->request->baseUrl.'/data/avatar/'.$model->avatar,null,
                    array(
                        'width'=>'50px',
                        'height'=>'50px',
                    )); ?></div>
                <div class="td3"></div>
            </div>
            <?php endif; ?>
        
        	<div class="tr">
        		<div class="td"><?= $form->label($model,'avatar'); ?></div>
        		<div class="td2"><?= $form->fileField($model,'avatar',array('class'=>'input')); ?></div>
        		<div class="td3"><?= $form->error($model,'avatar'); ?></div>
        	</div>
        
        	<div class="tr">
        		<div class="td"><?= $form->label($model,'role'); ?></div>
        		<div class="td2"><?= $form->dropDownList($model,'role',User::model()->getRoleUserArray(),array('class'=>'input')); ?></div>
        		<div class="td3"><?= $form->error($model,'role'); ?></div>
        	</div>
        
        	<div class="tr">
        		<div class="td"><?= $form->label($model,'status'); ?></div>
        		<div class="td2"><?= $form->dropDownList($model,'status',User::getStatusArray(),array('class'=>'input')); ?></div>
        		<div class="td3"><?= $form->error($model,'status'); ?></div>
        	</div>
        
        	<div class="tr">
                <div class="td"></div>
        		<div class="td2">
                    <?= CHtml::submitButton(Yii::t('BackEnd','Update'), array('class'=>'button')); ?>
                    <?= CHtml::resetButton(Yii::t('BackEnd','Reset'), array('class'=>'button')); ?>
                </div>
                <div class="td3"></div>
        	</div>
        
        <?php $this->endWidget(); ?>
        </div>
        </div><!-- form -->
    </div>
</section>